package cn.learn.service.system.dept.impl;

import cn.learn.dao.system.dept.DeptDao;
import cn.learn.domain.system.dept.Dept;
import cn.learn.service.system.dept.DeptService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DeptServiceImpl implements DeptService {

    @Autowired
    private DeptDao deptDao;

    /**
     * 分页查询全部内容
     * @param pageNum
     * @param pageSize
     * @param companyId
     * @return
     */
    @Override
    public PageInfo selectAllByPage(int pageNum, int pageSize, String companyId) {
        PageHelper.startPage(pageNum, pageSize);
        List<Dept> resultDept =  deptDao.selectAll(companyId);
        PageInfo resultData = new PageInfo(resultDept);
        return resultData;
    }

    /**
     * 查询全部用于添加
     * @return
     */
    @Override
    public List<Dept> selectAll(String companyId) {
        List<Dept> resultList = deptDao.selectAll(companyId);
        return resultList;
    }

    /**
     * 添加一条
     * @param dept
     */
    @Override
    public void addOne(Dept dept) {
        deptDao.addOne(dept);
    }

    /**
     * 根据id查询一条
     * @param dept
     * @return
     */
    @Override
    public Dept findOneById(Dept dept) {
        Dept resultDept = deptDao.selectOneById(dept);
        return resultDept;
    }

    /**
     * 修改一条数据
     * @param dept
     */
    @Override
    public void updateBuId(Dept dept) {
        deptDao.updateBuId(dept);
    }

    /**
     * 根据ID删除一条数据
     * @param id
     */
    @Override
    public void deleteBuId(String id) {
        deptDao.deleteById(id);
    }


}
